﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PMS.XCMG.Util;
using static PMS.XCMG.Entity.Enums.Enums;

namespace PMS.XCMG.Entity
{
    /// <summary>
    /// 调度路径配置
    /// </summary>
    public partial class DispathPathConfig : BusEntity
    {
        /// <summary>
        /// 电气信号逻辑地址
        /// </summary>
        public string Key { get; set; }

        /// <summary>
        /// 编码
        /// </summary>
        public string Code { get; set; }

        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 启用状态
        /// </summary>
        public bool IsEnabled { set; get; }  
    }

    public partial class DispathPathConfig : BusEntity
    {
        public virtual List<ResponseVarToMPCodeConfig> VarToMPCodeConfigs { get; set; }
    }

    /// <summary>
    /// 实体配置
    /// OnModelCreating
    /// </summary>
    public class DispathPathConfigTypeConfig : BusEntityTypeConfig<DispathPathConfig>, IEntityTypeConfiguration<DispathPathConfig>
    {
        public override void Configure(EntityTypeBuilder<DispathPathConfig> builder)
        {
            base.Configure(builder);

            #region 主外键关系
            builder.HasKey(k => k.Id);//设置主键  
            #endregion

            #region 字段属性:最大长度,是否必需,默认值
            builder.Property(p => p.Code).HasMaxLength(EntityDefinition.DefSmallColLen).IsRequired();
            builder.Property(p => p.Key).HasMaxLength(EntityDefinition.DefSmallColLen).IsRequired();
            builder.Property(p => p.Name).HasMaxLength(EntityDefinition.DefSmallColLen).IsRequired();
            builder.Property(p => p.IsEnabled).HasMaxLength(EntityDefinition.DefSmallColLen).IsRequired(); 
            #endregion

            #region 备注
            builder.HasComment("DispathPathConfig");
            builder.Property(p => p.Code).HasComment("编码");
            builder.Property(p => p.Name).HasComment("名称");
            builder.Property(p => p.Key).HasComment("电气信号逻辑地址");
            builder.Property(p => p.IsEnabled).HasComment("启用状态"); 
            #endregion

            #region 种子数据  

            #region 拼版卷圆到纵缝焊接
            //N1
            builder.HasData(new DispathPathConfig
            {
                Id = "N1",
                Key = "S7Net.ZFHJ.WeidingCall_AGV1",
                Code = "N1",
                Name = "前锥拼版区要料",
                CreateTime = DateTime.Now,
                IsEnabled = true, 
            });

            //N2
            builder.HasData(new DispathPathConfig
            {
                Id = "N2",
                Key = "S7Net.ZFHJ.WeidingCall_AGV2",
                Code = "N2",
                Name = "前锥拼版区要料",
                CreateTime = DateTime.Now,
                IsEnabled = true, 
            });

            //N3
            builder.HasData(new DispathPathConfig
            {
                Id = "N3",
                Key = "S7Net.ZFHJ.WeidingCall_AGV3",
                Code = "N3",
                Name = "前锥拼版区要料",
                CreateTime = DateTime.Now,
                IsEnabled = true, 
            });

            //n1
            builder.HasData(new DispathPathConfig
            {
                Id = "s_n1",
                Key = "S7Net.PBJYQ.ReadJYJ1MoveIn_Request",
                Code = "n1",
                Name = "卷圆机要框",
                CreateTime = DateTime.Now,
                IsEnabled = true, 
            });

            //n2
            builder.HasData(new DispathPathConfig
            {
                Id = "s_n2",
                Key = "S7Net.PBJYQ.ReadJYJ2MoveIn_Request",
                Code = "n2",
                Name = "卷圆机要框",
                CreateTime = DateTime.Now,
                IsEnabled = true, 
            });

            //n3
            builder.HasData(new DispathPathConfig
            {
                Id = "s_n3",
                Key = "S7Net.PBJYQ.ReadJYJ3MoveIn_Request",
                Code = "n3",
                Name = "卷圆机要框",
                CreateTime = DateTime.Now,
                IsEnabled = true, 
            });

            //n4
            builder.HasData(new DispathPathConfig
            {
                Id = "s_n4",
                Key = "S7Net.PBJYQ.ReadJYJ4MoveIn_Request",
                Code = "n4",
                Name = "卷圆机要框",
                CreateTime = DateTime.Now,
                IsEnabled = true, 
            });

            //n5
            builder.HasData(new DispathPathConfig
            {
                Id = "s_n5",
                Key = "S7Net.PBJYQ.ReadJYJ5MoveIn_Request",
                Code = "n5",
                Name = "卷圆机要框",
                CreateTime = DateTime.Now,
                IsEnabled = true, 
            });

            //n6
            builder.HasData(new DispathPathConfig
            {
                Id = "s_n6",
                Key = "S7Net.PBJYQ.ReadJYJ6MoveIn_Request",
                Code = "n6",
                Name = "卷圆机要框",
                CreateTime = DateTime.Now,
                IsEnabled = true, 
            });
            #endregion

            #region 立式组队1
            //O1
            builder.HasData(new DispathPathConfig
            {
                Id = "O1",
                Key = "S7Net.LSZD1.ReadBeforeMoveIn_Request",
                Code = "O1",
                Name = "立式组队中锥要料请求",
                CreateTime = DateTime.Now,
                IsEnabled = true, 
            });

            //P1
            builder.HasData(new DispathPathConfig
            {
                Id = "P1",
                Key = "S7Net.LSZD1.ReadMid_CalfMoveIn_Request",
                Code = "P1",
                Name = "立式组队中桶要料请求",
                CreateTime = DateTime.Now,
                IsEnabled = true, 
            });

            //R1
            builder.HasData(new DispathPathConfig
            {
                Id = "R1",
                Key = "S7Net.LSZD1.ReadCentreMoveIn_Request",
                Code = "R1",
                Name = "立式组队前锥要料请求",
                CreateTime = DateTime.Now,
                IsEnabled = true, 
            });

            //o2
            builder.HasData(new DispathPathConfig
            {
                Id = "s_o2",
                Key = "S7Net.LSZD1.o2",
                Code = "o2",
                Name = "立式组队中锥缓存位搬出请求",
                CreateTime = DateTime.Now,
                IsEnabled = true, 
            });
            //o3
            builder.HasData(new DispathPathConfig
            {
                Id = "s_o3",
                Key = "S7Net.LSZD1.o3",
                Code = "o3",
                Name = "立式组队中锥缓存位搬出请求",
                CreateTime = DateTime.Now,
                IsEnabled = true, 
            });
            //o4
            builder.HasData(new DispathPathConfig
            {
                Id = "s_o4",
                Key = "S7Net.LSZD1.o4",
                Code = "o4",
                Name = "立式组队中锥缓存位搬出请求",
                CreateTime = DateTime.Now,
                IsEnabled = true, 
            });
            //o5
            builder.HasData(new DispathPathConfig
            {
                Id = "s_o5",
                Key = "S7Net.LSZD1.o5",
                Code = "o5",
                Name = "立式组队中锥缓存位搬出请求",
                CreateTime = DateTime.Now,
                IsEnabled = true, 
            }); 
            //p1
            builder.HasData(new DispathPathConfig
            {
                Id = "s_p1",
                Key = "S7Net.LSZD1.p1",
                Code = "p1",
                Name = "立式组队中桶缓存位搬出请求",
                CreateTime = DateTime.Now,
                IsEnabled = true, 
            });
            //p2
            builder.HasData(new DispathPathConfig
            {
                Id = "s_p2",
                Key = "S7Net.LSZD1.p2",
                Code = "p2",
                Name = "立式组队中桶缓存位搬出请求",
                CreateTime = DateTime.Now,
                IsEnabled = true, 
            });
            //p3
            builder.HasData(new DispathPathConfig
            {
                Id = "s_p3",
                Key = "S7Net.LSZD1.p3",
                Code = "p3",
                Name = "立式组队中桶缓存位搬出请求",
                CreateTime = DateTime.Now,
                IsEnabled = true, 
            });
            //p4
            builder.HasData(new DispathPathConfig
            {
                Id = "s_p4",
                Key = "S7Net.LSZD1.p4",
                Code = "p4",
                Name = "立式组队中桶缓存位搬出请求",
                CreateTime = DateTime.Now,
                IsEnabled = true, 
            });
            //p5
            builder.HasData(new DispathPathConfig
            {
                Id = "s_p5",
                Key = "S7Net.LSZD1.p5",
                Code = "p5",
                Name = "立式组队中桶缓存位搬出请求",
                CreateTime = DateTime.Now,
                IsEnabled = true, 
            });
            //r2
            builder.HasData(new DispathPathConfig
            {
                Id = "s_r2",
                Key = "S7Net.LSZD1.r2",
                Code = "r2",
                Name = "立式组队前锥缓存位搬出请求",
                CreateTime = DateTime.Now,
                IsEnabled = true, 
            });
            //r3
            builder.HasData(new DispathPathConfig
            {
                Id = "s_r3",
                Key = "S7Net.LSZD1.r3",
                Code = "r3",
                Name = "立式组队前锥缓存位搬出请求",
                CreateTime = DateTime.Now,
                IsEnabled = true, 
            });
            //r4
            builder.HasData(new DispathPathConfig
            {
                Id = "s_r4",
                Key = "S7Net.LSZD1.r4",
                Code = "r4",
                Name = "立式组队前锥缓存位搬出请求",
                CreateTime = DateTime.Now,
                IsEnabled = true, 
            });
            //r5
            builder.HasData(new DispathPathConfig
            {
                Id = "s_r5",
                Key = "S7Net.LSZD1.r5",
                Code = "r5",
                Name = "立式组队前锥缓存位搬出请求",
                CreateTime = DateTime.Now,
                IsEnabled = true, 
            });
              
            #endregion

            #endregion
        }
    }
}
